package Day1;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

public class Myservelt implements Servlet {
    public void init(ServletConfig servletConfig) throws ServletException {
        //初始化
        System.out.println("初始化成功...");
    }



    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        HttpServletRequest  request=(HttpServletRequest) servletRequest;
        String name= request.getMethod();
        if("GET".equals(name)){
            doGet(servletRequest,servletResponse);
        }
        else if("POST".equals(name)){
            doPost(servletRequest,servletResponse);
        }
    }

    protected void doPost(ServletRequest servletRequest, ServletResponse servletResponse) {
        System.out.println("进行doPost...");}

   protected void doGet(ServletRequest servletRequest, ServletResponse servletResponse) {
        System.out.println("进行doGet...");
    }

    public ServletConfig getServletConfig() {
        return null;
    }
    public String getServletInfo() {
        return null;
    }

    public void destroy() {

    }
}
